<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions">

<xsl:output method="html" encoding="UTF-8"/>

<xsl:template match="/">
<html>
<head><title>Vārdnīca</title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
<style type="text/css">
body {
    font-family: "Times New Roman";    
}
h2 {
    font-size: 120%; 
}
div.term {
    display: block;
    margin: 0px;
}
p.label {
    margin: 0px;
    width: 100px;
    text-align:right;
    float:left;
}
p.explanation
    margin: 0px;
    float:left;
}
</style>
</head>

<body>
<xsl:for-each select="//letter">
<h2><xsl:value-of select="@title"/></h2>
<xsl:for-each select="term">
<xsl:sort select="sort" lang="fr" data-type="text" order="ascending"/>
<xsl:sort select="." lang="fr" data-type="text" order="ascending"/>
<xsl:sort select="string-length(@fr) - string-length(sort)" data-type="number" order="ascending"/>
<xsl:sort select="substring-before(concat(@loc,','),',')" data-type="number" order="ascending"/>
<div class="term">
<xsl:value-of select="concat(../@title,position())"/>. 
<xsl:value-of select="@fr"/> {<xsl:value-of select="@loc"/>}  <xsl:if test="normalize-space(@lv) = ''"><b>*_____</b></xsl:if>
<xsl:value-of select="@lv"/>  
</div>
</xsl:for-each>
</xsl:for-each>

</body>
</html>
</xsl:template>


</xsl:stylesheet>
